package com.gj.xxl.job.executor.config;

import com.gj.xxl.job.core.executor.GjJobSpringExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GjJobConfig {

    @Value("${xxl.job.admin.addresses}")
    private String adminAddresses;

    @Value("${xxl.job.accessToken}")
    private String accessToken;

    @Value("${xxl.job.executor.appname}")
    private String appname;

    @Value("${xxl.job.executor.address}")
    private String address;

    @Value("${xxl.job.executor.ip}")
    private String ip;

    @Value("${xxl.job.executor.port}")
    private int port;


    @Bean
    public GjJobSpringExecutor gjJobSpringExecutor() {
        GjJobSpringExecutor gjJobSpringExecutor = new GjJobSpringExecutor();
        gjJobSpringExecutor.setAdminAddresses(adminAddresses);
        gjJobSpringExecutor.setAppname(appname);
        gjJobSpringExecutor.setAddress(address);
        gjJobSpringExecutor.setIp(ip);
        gjJobSpringExecutor.setPort(port);
        gjJobSpringExecutor.setAccessToken(accessToken);

        return gjJobSpringExecutor;
    }

}
